package br.com.edoc.entidade;



import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table (name="MENU")
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name="ME_IDDOOBJETO")
public class Menu implements EntidadePadrao{

	
	/**
	 * 
	 */
	private static final long serialVersionUID = -6557242690356745888L;
	@Id  
	@Column(name = "ME_IDDOOBJETO", nullable = false)  
	@GeneratedValue(strategy=GenerationType.IDENTITY)  
	private Integer id;
	@ManyToOne (cascade={CascadeType.PERSIST})
	@JoinColumn(name="MOD_IDDOOBJETO")
	private Modulo modulo;
	@Column(name = "ME_DESCRICAO", nullable = false, length=50)
	private String descricao;
	@ManyToOne (cascade={CascadeType.PERSIST})
	@JoinColumn(name="ME_MOTHER")
	private Menu mother;
	@Transient
	private Integer tipoMenu;
	
	

	public Menu() {
		super();
	}

	public Menu(Modulo modulo, Menu mother) {
		super();
		this.modulo = modulo;
		this.mother = mother;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	

	public String getDescricao() {
		return descricao;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}

	public Modulo getModulo() {
		return modulo;
	}

	public void setModulo(Modulo modulo) {
		this.modulo = modulo;
	}

	public Menu getMother() {
		return mother;
	}

	public void setMother(Menu mother) {
		this.mother = mother;
	}

	public Integer getTipoMenu() {
		if(this instanceof MenuFolha){
			tipoMenu = 1;
		}else{
			tipoMenu = 0;
		}
		return tipoMenu;
	}

	public void setTipoMenu(Integer tipoMenu) {
		this.tipoMenu = tipoMenu;
	}
	
	
}
